package chu.dejian.models;

import java.util.List;

import chu.dejian.entity.MeasureMessageEntity;

/**
 * Created by Administrator on 2015/11/28 0028.
 */
public class GetAttenderMessagesResponse {

    /**
     * next :
     * prev :
     * total : 3
     * page : 1
     * results : [{"am_id":9,"attendee":"leeboo-user","attendee_uid":197,"level":3,"content":{"pulsestate":"normal","pulse":65,"note":"","systolic":126,"message":"血压脉搏正常","diastolic":78},"time":"2016-01-15 14:24:46","measurement":97,"location":""},{"am_id":6,"attendee":"leeboo-user","attendee_uid":197,"level":3,"content":{"pulsestate":"normal","pulse":65,"note":"","systolic":126,"message":"血压脉搏正常","diastolic":78},"time":"2016-01-06 19:31:44","measurement":69,"location":""},{"am_id":5,"attendee":"leeboo-user","attendee_uid":197,"level":3,"content":{"pulsestate":"normal","pulse":65,"note":"","systolic":126,"message":"血压脉搏正常","diastolic":78},"time":"2016-01-06 19:25:03","measurement":66,"location":""}]
     */

    private String next;
    private String prev;
    private int total;
    private int page;

    @Override
    public String toString() {
        return "GetAttenderMessagesResponse{" +
                "next='" + next + '\'' +
                ", prev='" + prev + '\'' +
                ", total=" + total +
                ", page=" + page +
                ", results=" + results +
                '}';
    }

    private List<ResultsEntity> results;

    public String getNext() {
        return next;
    }

    public void setNext(String next) {
        this.next = next;
    }

    public String getPrev() {
        return prev;
    }

    public void setPrev(String prev) {
        this.prev = prev;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public List<ResultsEntity> getResults() {
        return results;
    }

    public void setResults(List<ResultsEntity> results) {
        this.results = results;
    }

    /**
     * am_id : 9
     * attendee : leeboo-user
     * attendee_uid : 197
     * level : 3
     * content : {"pulsestate":"normal","pulse":65,"note":"","systolic":126,"message":"血压脉搏正常","diastolic":78}
     * time : 2016-01-15 14:24:46
     * measurement : 97
     * location :
     */
    public static class ResultsEntity {
        private int am_id;
        private String attendee;
        private int attendee_uid;
        private int level;
        private ContentEntity content;
        private String time;
        private int measurement;
        private String location;


        public MeasureMessageEntity toMeasureMessageEntity(){
            MeasureMessageEntity messageEntity = new MeasureMessageEntity();
            messageEntity.messageId = am_id;
            messageEntity.attendee = attendee;
            messageEntity.attendee_uid = attendee_uid;
            messageEntity.level=level;
            messageEntity.timeStr = time;
            messageEntity.measurement = measurement;
            if(content != null){
                messageEntity.pulse = content.pulse;
                messageEntity.pulsestate = content.pulsestate;
                messageEntity.note = content.note;
                messageEntity.systolic = content.systolic;
                messageEntity.diastolic = content.diastolic;
                messageEntity.message = content.message;
            }
           if(location != null && location.contains(",")){
               String[] lcas = location.split(",");
               if(lcas.length >= 2){
                   messageEntity.latitude = Double.parseDouble(lcas[0]);
                   messageEntity.longitude = Double.parseDouble(lcas[1]);
               }
           }
            return messageEntity;
        }

        public int getAm_id() {
            return am_id;
        }

        public void setAm_id(int am_id) {
            this.am_id = am_id;
        }

        public String getAttendee() {
            return attendee;
        }

        public void setAttendee(String attendee) {
            this.attendee = attendee;
        }

        public int getAttendee_uid() {
            return attendee_uid;
        }

        public void setAttendee_uid(int attendee_uid) {
            this.attendee_uid = attendee_uid;
        }

        public int getLevel() {
            return level;
        }

        public void setLevel(int level) {
            this.level = level;
        }

        public ContentEntity getContent() {
            return content;
        }

        public void setContent(ContentEntity content) {
            this.content = content;
        }

        public String getTime() {
            return time;
        }

        public void setTime(String time) {
            this.time = time;
        }

        public int getMeasurement() {
            return measurement;
        }

        public void setMeasurement(int measurement) {
            this.measurement = measurement;
        }

        public String getLocation() {
            return location;
        }

        public void setLocation(String location) {
            this.location = location;
        }

        @Override
        public String toString() {
            return "ResultsEntity{" +
                    "am_id=" + am_id +
                    ", attendee='" + attendee + '\'' +
                    ", attendee_uid=" + attendee_uid +
                    ", level=" + level +
                    ", content=" + content +
                    ", time='" + time + '\'' +
                    ", measurement=" + measurement +
                    ", location='" + location + '\'' +
                    '}';
        }


        /**
         * pulsestate : normal
         * pulse : 65
         * note :
         * systolic : 126
         * message : 血压脉搏正常
         * diastolic : 78
         */
        public static class ContentEntity {
            private String pulsestate;
            private int pulse;
            private String note;
            private int systolic;
            private String message;
            private int diastolic;

            public String getPulsestate() {
                return pulsestate;
            }

            public void setPulsestate(String pulsestate) {
                this.pulsestate = pulsestate;
            }

            public int getPulse() {
                return pulse;
            }

            public void setPulse(int pulse) {
                this.pulse = pulse;
            }

            public String getNote() {
                return note;
            }

            public void setNote(String note) {
                this.note = note;
            }

            public int getSystolic() {
                return systolic;
            }

            public void setSystolic(int systolic) {
                this.systolic = systolic;
            }

            public String getMessage() {
                return message;
            }

            public void setMessage(String message) {
                this.message = message;
            }

            public int getDiastolic() {
                return diastolic;
            }

            public void setDiastolic(int diastolic) {
                this.diastolic = diastolic;
            }

            @Override
            public String toString() {
                return "ContentEntity{" +
                        "pulsestate='" + pulsestate + '\'' +
                        ", pulse=" + pulse +
                        ", note='" + note + '\'' +
                        ", systolic=" + systolic +
                        ", message='" + message + '\'' +
                        ", diastolic=" + diastolic +
                        '}';
            }
        }
    }
}
